<?php

/**
 * Pwiff - PHP SWF Library
 *
 * LICENSE
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 *
 * @package    Pwiff
 * @subpackage Records
 * @copyright  Copyright (c) 2010 Steven Harris
 * @license    http://www.opensource.org/licenses/bsd-license.php New BSD License
 * @version    $Id: StyleChange.php 8 2010-02-22 04:06:23Z indigo.sunrise $
 */

/**
 * The StyleChangeRecord.
 *
 * @package    Pwiff
 * @subpackage Records
 */
class Pwiff_Record_Shape_StyleChange extends Pwiff_Record_Shape_NonEdge
{
	
	protected $moveDeltaX = 0;
	
	protected $moveDeltaY = 0;
	
	protected $fillStyle0 = 0;
	
	protected $fillStyle1 = 0;
	
	protected $lineStyle = 0;
	
	// make sure if one of these is set, and the other is not, the other
	// gets set to an empty one as the format requires both to exist.
	protected $newFillStyles = null;
	
	protected $newLineStyles = null;
	
	
	/**
	 * Gets the number of fill bits for the new fill style array.
	 * 
	 * @return int
	 */
	public function getFillBits()
	{
		if ($this->newFillStyles === null) {
			return 0;
		}
		
		return Pwiff_Util_Numerics::getUnsignedBitCount(
			$this->newFillStyles->getFillStyleCount()
		);
	}
	
	/**
	 * Gets the number of line bits for the new line style array.
	 * 
	 * @return int
	 */
	public function getLineBits()
	{
		if ($this->newLineStyles === null) {
			return 0;
		}
		
		return Pwiff_Util_Numerics::getUnsignedBitCount(
			$this->newLineStyles->getLineStyleCount()
		);
	}
	
	/**
	 * Gets the length of the record. This is handled in
	 * Pwiff_Record_Shape::getStyleChangeLength() as it relies on data
	 * organized in the Shape.
	 *
	 * @return int
	 */
	public function getRecordLength()
	{
		return 0;
	}
	
	/**
	 * Writes the StyleChange shape record.
	 * 
	 * @param  Pwiff_Output $out
	 */
	public function write(Pwiff_Output $out)
	{
		parent::write($out);
		
		
	}
	
	/**
	 * Gets the number of bits to store the move values.
	 * 
	 * @return int
	 */
	public function getMoveBits()
	{
		return Pwiff_Util_Numerics::getSignedBitCount(array(
			$this->moveDeltaX,
			$this->moveDeltaY,
		));
	}
	

}
